<?php
/** Copyright 2014 TinPhp Systems, Inc.
 * @author zhangxilian 2013-8-20
 * @package TinPhp
 */
require_once(TIN_APP_PATH . 'configs/site.conf.php');
require_once(TIN_APP_PATH . 'include/TinPHP/exception/TinParseException.php');
/** 创建Soap服务端类 */
class PHYServer extends SoapServer {
	static $uri = TIN_PHY_URI;
	public $user_name;
	public $pass_word;
	/**
	 * 验证用户名和密码的用户信息
     * @param string $user_name 用户名
     * @param string $pass_word 密码
     * @return bool
	 */
	public function greet($user_name, $pass_word) {
		if ($user_name == TIN_PHY_USERNAME && $pass_word == TIN_PHY_PASSWORD) {
			$auth = 1;
		} else {
			$auth = 0;
		}
		if ($auth == 1) {
			return true;
		} else {
			return false;
		}
	}
	/** 新建SOAP Service
	 * @param $user_name 服务通信用户名 
	 * @param $pass_word 服务通信密码
	 * */
	public function __construct($user_name='', $pass_word='') {
		$this->user_name = $user_name;
		$this->pass_word = $pass_word;
		if ($this->greet($this->user_name, $this->pass_word)) {
			parent :: SoapServer(null, array ('uri' => self :: $uri,"encoding" => "UTF-8"));
		} else {
			throw new TinParseException("Api username or password was error");
		}
	}

}
?>
